home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / util / time / smallclock.lha / SmallClock / smallclock.s < prev   
Text File  |  1995-10-06  |  14KB  |  824 lines

  1. ;----------------------------------------------------------------------------
  2. ; smallclock v39.0 by Morten Amundsen
  3. ;
  4. ; start: Wednesday, 20/09 1995, 03:31 PM
  5. ;   end: Wednesday, 20/09 1995, 08:16 PM
  6. ;
  7. ; smallclock v39.01 (Added FRONTPEN and BACKPEN tooltypes)
  8. ;
  9. ; start: Sunday, 01/10 1995, 07:40 PM
  10. ;   end: Sunday, 01/10 1995, 07:50 PM
  11. ;
  12. ; smallclock v39.02 (Made a better estimate of window width)
  13. ;
  14. ; start: Friday, 06/10 1995, 09:40 PM
  15. ;   end: Friday, 06/10 1995, 09:45 PM
  16. ;
  17. ;
  18. ; Coded in PhxAss 4.20 
  19. ;-----------------------------------------------------------------------------
  20.  
  21. VERSION    = 39                        ; kick version
  22. WB    = 1                        ; wb startup (0=no)
  23.  
  24. ;-----------------------------------------------------------------------------
  25.  
  26. NAME:    MACRO
  27.     dc.b    "SmallClock "
  28.     ENDM
  29.  
  30. VER:    MACRO
  31.     dc.b    "39"
  32.     ENDM
  33.  
  34. REV:    MACRO
  35.     dc.b    "02"
  36.     ENDM
  37.  
  38. DATE:    MACRO
  39.     dc.b    "(6.10.95)"
  40.     ENDM
  41.  
  42. VERSTR:    MACRO
  43.     dc.b    "$VER: "
  44.     NAME
  45.     VER
  46.     dc.b    "."
  47.     REV
  48.     dc.b    " "
  49.     DATE
  50.     dc.b    10,13,0
  51.     ENDM
  52.  
  53. ;-----------------------------------------------------------------------------
  54.  
  55.     incdir    "include:"
  56.     include    "misc/lvooffsets.i"
  57.     include    "misc/macros.i"
  58.     include    "graphics/gfxbase.i"
  59.     include    "libraries/commodities.i"
  60.     include    "dos/dosextens.i"
  61.     include    "devices/timer.i"
  62.     include    "graphics/text.i"
  63.     include    "intuition/intuition.i"
  64.     include    "intuition/screens.i"
  65.     include    "libraries/commodities.i"
  66.     include    "workbench/startup.i"
  67.     include    "workbench/workbench.i"
  68.  
  69.     XDEF    _main
  70.     XDEF    _SysBase
  71.     XDEF    _DOSBase
  72.     XDEF    _GfxBase
  73.     XDEF    _CxBase
  74.     XDEF    _IconBase
  75.     XDEF    _stdout
  76.  
  77. _main:    movem.l    d0-d7/a0-a6,-(a7)
  78.  
  79.     IFD WB
  80.     bsr.w    FIND_WBMSG
  81.     ENDC
  82.  
  83.     OPENLIB    DOSName,VERSION,_DOSBase
  84.     beq.s    EXIT
  85.     OPENLIB    GfxName,VERSION,_GfxBase
  86.     beq.s    EXIT
  87.     OPENLIB    UtilityName,VERSION,_UtilityBase
  88.     beq.s    EXIT
  89.     OPENLIB IntuitionName,VERSION,_IntuitionBase
  90.     beq.s    EXIT
  91.     OPENLIB    CxName,VERSION,_CxBase
  92.     beq.s    EXIT
  93.     OPENLIB IconName,VERSION,_IconBase
  94.     beq.s    EXIT
  95.  
  96.     CALL    Output,_DOSBase
  97.     move.l    d0,_stdout
  98.  
  99.     tst.l    _WBMsg
  100.     beq.s    FROM_SHELL            ; get arguments from commandline
  101.  
  102.     CALL    GetProgramDir,_DOSBase        ; CD to PROGDIR:
  103.     move.l    d0,d1
  104.     CALL    CurrentDir,_DOSBase
  105.     move.l    d0,_OldLock
  106.  
  107.     move.l    _WBMsg,a0
  108.     move.l    sm_ArgList(a0),a0
  109.     move.l    wa_Name(a0),a0
  110.     CALL    GetDiskObject,_IconBase        ; get icon
  111.     move.l    d0,_DiskObject
  112.     beq    SETUP_CX
  113.  
  114.     move.l    _DiskObject,a0            ; read tooltypes
  115.     move.l    do_ToolTypes(a0),a0
  116.     lea    CXPRI_Text,a1
  117.     CALL    FindToolType,_IconBase
  118.     moveq    #0,d7            ; default value
  119.     bsr    STR2INT
  120.  
  121.     lea    New_Broker,a1
  122.     move.b    d0,nb_Pri(a1)        ; CX_PRIORITY=
  123.  
  124.     move.l    _DiskObject,a0
  125.     move.l    do_ToolTypes(a0),a0
  126.     lea    CXXPOS_Text,a1
  127.     CALL    FindToolType,_IconBase
  128.     moveq    #0,d7            ; default value
  129.     bsr    STR2INT
  130.  
  131.     move.l    d0,WndXPos        ; XPOS=
  132.  
  133.     move.l    _DiskObject,a0
  134.     move.l    do_ToolTypes(a0),a0
  135.     lea    CXYPOS_Text,a1
  136.     CALL    FindToolType,_IconBase
  137.     moveq    #0,d7            ; default value
  138.     bsr    STR2INT
  139.  
  140.     move.l    d0,WndYPos        ; YPOS=
  141.  
  142.     move.l    _DiskObject,a0
  143.     move.l    do_ToolTypes(a0),a0
  144.     lea    CXFPEN_Text,a1
  145.     CALL    FindToolType,_IconBase
  146.     moveq    #0,d7            ; default value
  147.     bsr    STR2INT
  148.  
  149.     move.l    d0,FrontPen        ; FRONTPEN=
  150.  
  151.     move.l    _DiskObject,a0
  152.     move.l    do_ToolTypes(a0),a0
  153.     lea    CXBPEN_Text,a1
  154.     CALL    FindToolType,_IconBase
  155.     moveq    #1,d7            ; default value
  156.     bsr    STR2INT
  157.  
  158.     move.l    d0,BackPen        ; BACKPEN=
  159.  
  160.  
  161.     move.l    _DiskObject,a0
  162.     CALL    FreeDiskObject,_IconBase
  163.  
  164.     move.l    _OldLock,d1        ; CD to original dir.
  165.     CALL    CurrentDir,_DOSBase
  166.     bra.s    SETUP_CX
  167.  
  168. FROM_SHELL:
  169.     move.l    #TEMPLATE,d1        ; read commandline
  170.     move.l    #Arguments,d2
  171.     moveq    #0,d3
  172.     CALL    ReadArgs,_DOSBase
  173.     move.l    d0,_RDArgs
  174.     bne.s    OKARG
  175.  
  176.     CALL    IoErr,_DOSBase        ; woops! syntax error!
  177.  
  178.     move.l    d0,d1
  179.     moveq    #0,d2
  180.     CALL    PrintFault,_DOSBase    ; why!?
  181.     bra    EXIT
  182.  
  183. OKARG:    lea    Arguments,a0
  184.     move.l    (a0)+,d0
  185.     lea    New_Broker,a1
  186.     move.b    d0,nb_Pri(a1)        ; CX_PRIORITY=
  187.     move.l    (a0)+,a1
  188.     move.l    (a1),WndXPos        ; XPOS=
  189.     move.l    (a0)+,a1
  190.     move.l    (a1),WndYPos        ; YPOS=
  191.     move.l    (a0)+,a1
  192.     move.l    (a1),FrontPen        ; FRONTPEN=
  193.     move.l    (a0),a1
  194.     move.l    (a1),BackPen        ; BACKPEN
  195.  
  196. SETUP_CX:
  197.     EXEC    CreateMsgPort
  198.     move.l    d0,_BrokerPort
  199.     beq    EXIT
  200.  
  201.     lea    New_Broker,a0
  202.     move.l    d0,nb_Port(a0)
  203.     moveq    #0,d0
  204.     CALL    CxBroker,_CxBase
  205.     move.l    d0,_Broker
  206.     beq    EXIT
  207.  
  208.     moveq    #0,d1
  209.     move.l    _BrokerPort,a0
  210.     move.b    MP_SIGBIT(a0),d0
  211.     bset    d0,d1
  212.     move.l    d1,_CxSigSet
  213.  
  214. ;-------------------------------------------------------------------------------------
  215.  
  216. T3:    SETTAG    #WindowTags,WA_Left,WndXPos        ; clock window position
  217. T4:    SETTAG    #WindowTags,WA_Top,WndYPos
  218.  
  219.     lea    WBName,a0
  220.     CALL    LockPubScreen,_IntuitionBase
  221.     move.l    d0,_WBScr
  222.     beq    EXIT
  223.  
  224.     move.l    d0,a0
  225.     move.l    sc_Font(a0),a0                ; get screen font
  226.     lea    TimeIText,a1
  227.     move.l    a0,it_ITextFont(a1)
  228.  
  229.     CALL    OpenFont,_GfxBase
  230.     move.l    d0,_WBFont
  231.     beq    EXIT
  232.  
  233.     moveq    #0,d2
  234.     moveq    #0,d3
  235.     move.l    d0,a0
  236.     move.w    tf_YSize(a0),d2                ; check it x/y size
  237.     addq.w    #2,d2
  238.     move.w    d2,WndYSize
  239. T1:    SETTAG    #WindowTags,WA_Height,d2        ; clock window y size
  240.  
  241.     lea    TimeIText,a0
  242.     CALL    IntuiTextLength,_IntuitionBase
  243.     move.w    d0,WndXSize
  244.     move.w    d0,d3
  245.  
  246. T2:    SETTAG    #WindowTags,WA_Width,d3
  247.  
  248.     lea    TimeIText,a0
  249.     move.l    #NULL,it_ITextFont(a0)
  250.  
  251.     lea    WBName,a0
  252.     CALL    UnlockPubScreen,_IntuitionBase
  253.  
  254.     sub.l    a0,a0
  255.     lea    WindowTags,a1
  256.     CALL    OpenWindowTagList,_IntuitionBase
  257.     move.l    d0,_Window
  258.     beq    EXIT
  259.  
  260.     move.l    d0,a0
  261.     move.l    wd_RPort(a0),a1
  262.     move.l    _WBFont,a0
  263.     CALL    SetFont,_GfxBase    ; use WBFont in our window
  264.  
  265. ;-------------------------------------------------------------------------------------
  266.  
  267.     EXEC    CreateMsgPort
  268.     move.l    d0,_TimerMP
  269.     beq    EXIT
  270.  
  271.     moveq    #0,d2
  272.     move.l    d0,a0
  273.     move.b    MP_SIGBIT(a0),d1
  274.     bset    d1,d2
  275.     move.l    d2,_TimerSigBit
  276.  
  277.     move.l    d0,a0
  278.     move.l    #IOTV_SIZE,d0
  279.     EXEC    CreateIORequest
  280.     move.l    d0,_TimerIO
  281.     beq    EXIT
  282.  
  283.     lea    TimerName,a0
  284.     moveq    #UNIT_VBLANK,d0
  285.     move.l    _TimerIO,a1
  286.     moveq    #0,d0
  287.     EXEC    OpenDevice
  288.  
  289.     move.l    _TimerIO,a0
  290.     move.l    IO_DEVICE(a0),_TimerBase
  291.     beq    EXIT
  292.  
  293.     move.l    _Broker,a0
  294.     moveq    #TRUE,d0
  295.     CALL    ActivateCxObj,_CxBase
  296.  
  297.     move.w    #TRUE,ClockON
  298.  
  299.     move.l    _Window,a1
  300.     move.l    wd_RPort(a1),a1
  301.     move.l    BackPen,d0
  302.     CALL    SetAPen,_GfxBase
  303.  
  304.     move.l    FrontPen,d0
  305.     move.l    BackPen,d1
  306.     lea    TimeIText,a0
  307.     move.b    d0,(a0)            ; frontpen
  308.     move.b    d1,1(a0)        ; backpen
  309.  
  310. CLOCK_LOOP:
  311.     moveq    #0,d0
  312.  
  313.     tst.w    ClockON
  314.     beq.s    NO_CLOCK
  315.  
  316.     move.l    _TimerIO,a1
  317.     move.w    #TR_ADDREQUEST,IO_COMMAND(a1)        ; wait a second!!
  318.     lea    IOTV_TIME(a1),a0
  319.     move.l    #1,TV_SECS(a0)
  320.     move.l    #0,TV_MICRO(a0)
  321.     EXEC    SendIO
  322.  
  323.     move.l    _TimerSigBit,d0
  324.  
  325. NO_CLOCK:
  326.     or.l    _CxSigSet,d0                ; wait for CTRL-C, CX and timer
  327.     or.l    #SIGBREAKF_CTRL_C,d0
  328.     EXEC    Wait
  329.  
  330.     move.l    d0,d1
  331.     and.l    #SIGBREAKF_CTRL_C,d1
  332.     bne    EXIT
  333.  
  334.     move.l    d0,d1
  335.     move.l    _CxSigSet,d2
  336.     and.l    d2,d1
  337.     beq    UPDATE_CLOCK
  338.  
  339. CXMSG_LOOP:
  340.     tst.w    ExitFlag
  341.     bne    EXIT
  342.  
  343.     move.l    _BrokerPort,a0
  344.     EXEC    GetMsg
  345.     move.l    d0,_CxMessage
  346.     beq    CLOCK_LOOP
  347.  
  348.     move.l    d0,a0
  349.     CALL    CxMsgID,_CxBase
  350.     move.l    d0,_CxID
  351.  
  352.     move.l    _CxMessage,a0
  353.     CALL    CxMsgType,_CxBase
  354.     move.l    d0,_CxType
  355.  
  356.     move.l    _CxMessage,a1
  357.     EXEC    ReplyMsg
  358.  
  359.     move.l    _CxType,d0
  360.     cmp.l    #CXM_COMMAND,d0            ; command from "Exchange"
  361.     bne    CXMSG_LOOP
  362.  
  363.     move.l    _CxID,d0
  364.     cmp.l    #CXCMD_UNIQUE,d0        ; quit if started twice!
  365.     bne.s    NOT_UNIQUE
  366.  
  367.     move.w    #1,ExitFlag
  368.     bra.s    CXMSG_LOOP
  369.  
  370. NOT_UNIQUE:
  371.     cmp.l    #CXCMD_KILL,d0            ; remove
  372.     bne.s    NOT_KILL
  373.  
  374.     move.w    #1,ExitFlag
  375.     bra.s    CXMSG_LOOP
  376.  
  377. NOT_KILL:
  378.     cmp.l    #CXCMD_ENABLE,d0        ; active
  379.     bne.s    NOT_ENABLE
  380.  
  381.     move.l    _Broker,a0
  382.     moveq    #TRUE,d0
  383.     CALL    ActivateCxObj,_CxBase
  384.     move.w    #TRUE,ClockON
  385.     bra.s    CXMSG_LOOP    
  386.  
  387. NOT_ENABLE:
  388.     cmp.l    #CXCMD_DISABLE,d0
  389.     bne    CXMSG_LOOP
  390.  
  391.     move.l    _Broker,a0
  392.     moveq    #FALSE,d0
  393.     CALL    ActivateCxObj,_CxBase        ; inactive
  394.     move.w    #FALSE,ClockON
  395.     bra.s    CXMSG_LOOP
  396.  
  397. UPDATE_CLOCK:
  398.     tst.w    ClockON
  399.     beq    CLOCK_LOOP
  400.  
  401.     lea    TimeVal,a0            ; get SysTime if Clock is active
  402.     CALL    GetSysTime,_TimerBase
  403.  
  404.     lea    TimeVal,a0
  405.  
  406.     move.l    TV_SECS(a0),d0
  407.     move.l    #60,d1
  408.     CALL    UDivMod32,_UtilityBase        ; calculate time of day
  409.     move.w    d1,Seconds
  410.     
  411.     move.l    #60,d1
  412.     CALL    UDivMod32,_UtilityBase
  413.     move.w    d1,Minutes
  414.  
  415.     move.l    #24,d1
  416.     CALL    UDivMod32,_UtilityBase
  417.     move.w    d1,Hours
  418.  
  419.     lea    HTxt,a0                ; convert into string
  420.     moveq    #0,d0
  421.     move.w    d1,d0
  422.     divu    #10,d0
  423.     add.b    #'0',d0
  424.     move.b    d0,(a0)
  425.     swap    d0
  426.     add.b    #'0',d0
  427.     move.b    d0,1(a0)
  428.  
  429.     lea    MTxt,a0
  430.     moveq    #0,d0
  431.     move.w    Minutes,d0
  432.     divu    #10,d0
  433.     add.b    #'0',d0
  434.     move.b    d0,(a0)
  435.     swap    d0
  436.     add.b    #'0',d0
  437.     move.b    d0,1(a0)
  438.  
  439.     lea    STxt,a0
  440.     moveq    #0,d0
  441.     move.w    Seconds,d0
  442.     divu    #10,d0
  443.     add.b    #'0',d0
  444.     move.b    d0,(a0)
  445.     swap    d0
  446.     add.b    #'0',d0
  447.     move.b    d0,1(a0)
  448.  
  449.     move.l    _Window,a1
  450.     move.l    wd_RPort(a1),a1
  451.     moveq    #0,d0
  452.     moveq    #0,d1
  453.     move.w    WndXSize,d2
  454.     move.w    WndYSize,d3
  455.     CALL    RectFill,_GfxBase        ; clear window
  456.  
  457.     move.l    _Window,a0
  458.     move.l    wd_RPort(a0),a0
  459.     lea    TimeIText,a1
  460.     moveq    #0,d0
  461.     moveq    #2,d1
  462.     CALL    PrintIText,_IntuitionBase    ; ohhh!? is it that much already?
  463.     bra    CLOCK_LOOP
  464.  
  465. EXIT:    bsr.w    CLEAN                ; bye!!!
  466.     movem.l    (a7)+,d0-d7/a0-a6
  467.     moveq    #0,d0
  468.     rts
  469.  
  470. ;-----------------------------------------------------------------------------
  471.  
  472.     IFD WB
  473.  
  474. FIND_WBMSG:
  475.     sub.l    a1,a1
  476.     CALLEXEC FindTask
  477.     move.l    d0,a4
  478.  
  479.     moveq    #0,d0
  480.  
  481.     tst.l    pr_CLI(a4)
  482.     bne.s    .CLI
  483.  
  484.     lea    pr_MsgPort(a4),a0
  485.     CALLEXEC WaitPort
  486.     lea    pr_MsgPort(a4),a0
  487.     CALLEXEC GetMsg
  488. .CLI:    move.l    d0,_WBMsg
  489.     rts
  490.  
  491. REPLY_WBMSG:
  492.     tst.l    _WBMsg
  493.     beq.s    .NOT
  494.  
  495.     move.l    _WBMsg,a1
  496.     CALLEXEC ReplyMsg
  497. .NOT:    rts
  498.  
  499.     ENDC
  500.  
  501. ;-----------------------------------------------------------------------------
  502.  
  503. CLEAN:    bsr.w    FREEARGS
  504.  
  505.     bsr.w    REMOVE_CX
  506.     bsr.w    CLOSE_CXPORT
  507.  
  508.     bsr.w    CLOSETIME
  509.     bsr.w    DEL_EXTIO
  510.     bsr.w    DEL_PORT
  511.  
  512.     bsr    CLOSEFNT
  513.     bsr    CLOSEWND
  514.  
  515.     bsr.w    CLOSEICN
  516.     bsr.w    CLOSEDOS
  517.     bsr.w    CLOSEGFX
  518.     bsr.w    CLOSEUTL
  519.     bsr.w    CLOSEINT
  520.     bsr.w    CLOSECX
  521.  
  522.     IFD WB
  523.     bsr.s    REPLY_WBMSG
  524.     ENDC
  525.     rts
  526.  
  527. ;------------------------------------------------------------------------------------
  528.  
  529. REMOVE_CX:
  530.     tst.l    _Broker
  531.     beq    .NOT
  532.  
  533.     move.l    _Broker,a0
  534.     CALL    DeleteCxObj,_CxBase
  535. .NOT:    rts
  536.  
  537. CLOSE_CXPORT:
  538.     tst.l    _BrokerPort
  539.     beq    .NOT
  540.     
  541.     move.l    _BrokerPort,a0
  542.     EXEC    DeleteMsgPort
  543. .NOT:    rts
  544.  
  545. FREEARGS:
  546.     tst.l    _RDArgs
  547.     beq    .NOT
  548.  
  549.     move.l    _RDArgs,d1
  550.     CALL    FreeArgs,_DOSBase
  551. .NOT:    rts
  552.  
  553. CLOSEFNT:
  554.     tst.l    _WBFont
  555.     beq    .NOT
  556.  
  557.     move.l    _WBFont,a1
  558.     CALL    CloseFont,_GfxBase
  559. .NOT:    rts
  560.  
  561. CLOSEWND:
  562.     tst.l    _Window
  563.     beq    .NOT
  564.  
  565.     move.l    _Window,a0
  566.     CALL    CloseWindow,_IntuitionBase
  567. .NOT:    rts
  568.  
  569. CLOSETIME:
  570.     tst.l    _TimerIO
  571.     beq    .NOT
  572.  
  573.     move.l    _TimerIO,a1
  574.     EXEC    CheckIO
  575.     tst.l    d0
  576.     bne    .PROG
  577.  
  578.     move.l    _TimerIO,a1
  579.     EXEC    AbortIO
  580.  
  581. .PROG:    move.l    _TimerIO,a1
  582.     EXEC    WaitIO
  583.  
  584.     move.l    _TimerIO,a1
  585.     EXEC    CloseDevice
  586. .NOT:    rts
  587.  
  588. DEL_EXTIO:
  589.     tst.l    _TimerIO
  590.     beq    .NOT
  591.  
  592.     move.l    _TimerIO,a0
  593.     EXEC    DeleteIORequest
  594. .NOT:    rts
  595.  
  596. DEL_PORT:
  597.     tst.l    _TimerMP
  598.     beq    .NOT
  599.  
  600.     move.l    _TimerMP,a0
  601.     EXEC    DeleteMsgPort
  602. .NOT:    rts
  603.  
  604. CLOSEICN:
  605.     tst.l    _IconBase
  606.     beq.s    .NOT
  607.  
  608.     CLOSELIB _IconBase
  609. .NOT:    rts
  610.  
  611. CLOSECX:
  612.     tst.l    _CxBase
  613.     beq.s    .NOT
  614.  
  615.     CLOSELIB _CxBase
  616. .NOT:    rts
  617.  
  618. CLOSEINT:
  619.     tst.l    _IntuitionBase
  620.     beq.s    .NOT
  621.  
  622.     CLOSELIB _IntuitionBase
  623. .NOT:    rts
  624.  
  625. CLOSEUTL:
  626.     tst.l    _UtilityBase
  627.     beq.s    .NOT
  628.  
  629.     CLOSELIB _UtilityBase
  630. .NOT:    rts
  631.  
  632. CLOSEDOS:
  633.     tst.l    _DOSBase
  634.     beq.s    .NOT
  635.  
  636.     CLOSELIB _DOSBase
  637. .NOT:    rts
  638.  
  639. CLOSEGFX:
  640.     tst.l    _GfxBase
  641.     beq.s    .NOT
  642.  
  643.     CLOSELIB _GfxBase
  644. .NOT:    rts
  645.  
  646. ;----------------------------------------------------------------------------
  647. ; NAME        STR2INT
  648. ; DESCRIPTION    Make a tooltype integer string into a long. If string is
  649. ;        incorrect, the default value will be returned.
  650. ; USAGE        value=STR2INT(string,default)
  651. ;        d0            d0     d7
  652. ;-----------------------------------------------------------------------------
  653.  
  654. STR2INT:
  655.     tst.l    d0                ; no string!
  656.     beq    S2I_DEFAULT
  657.  
  658.     move.l    d0,a0
  659.     tst.b    (a0)                ; string is empty!
  660.     beq    S2I_DEFAULT
  661.  
  662.     moveq    #0,d0
  663.     moveq    #0,d6
  664. S2I_LOOP:
  665.     tst.b    (a0)
  666.     beq.s    S2I_INTEGER            ; done!
  667.     cmp.b    #' ',(a0)
  668.     beq    S2I_NEXT            ; we've got a 'space', next please!
  669.  
  670.     cmp.b    #'0',(a0)
  671.     blo.s    S2I_DEFAULT
  672.     cmp.b    #'9',(a0)
  673.     bhi.s    S2I_DEFAULT
  674.  
  675.     move.b    (a0),d0                ; ok! a number between 0 and 9
  676.     sub.b    #'0',d0                ; convert to number
  677.     mulu    #10,d6                ; multiply what we already have by 10
  678.     add.l    d0,d6                ; and add this number
  679.  
  680. S2I_NEXT:
  681.     lea    1(a0),a0            ; next char
  682.     bra.s    S2I_LOOP
  683.  
  684. S2I_INTEGER:
  685.     move.l    d6,d0                ; we're done, return in d0
  686.     rts
  687.  
  688. S2I_DEFAULT:
  689.     move.l    d7,d0                ; error! return default value!
  690.     rts
  691.  
  692. ;-----------------------------------------------------------------------------
  693.  
  694.     section    "Data",data
  695.  
  696.     IFD WB
  697. _WBMsg:        dc.l    0
  698.     ENDC
  699.  
  700. _stdout:    dc.l    0
  701.  
  702. _RDArgs:    dc.l    0
  703.  
  704. _TimerIO:    dc.l    0
  705. _TimerMP:    dc.l    0
  706. _TimerSigBit:    dc.l    0
  707. _TimerBase:    dc.l    0    ; library base of timer.device
  708.  
  709. _DOSBase:    dc.l    0
  710. _GfxBase:    dc.l    0
  711. _UtilityBase:    dc.l    0
  712. _IntuitionBase:    dc.l    0
  713. _CxBase:    dc.l    0
  714. _IconBase:    dc.l    0
  715. IconName:    dc.b    "icon.library",0
  716. IntuitionName:    dc.b    "intuition.library",0
  717. DOSName:    dc.b    "dos.library",0
  718. GfxName:    dc.b    "graphics.library",0
  719. UtilityName:    dc.b    "utility.library",0
  720. CxName:        dc.b    "commodities.library",0
  721. TimerName:    dc.b    "timer.device",0
  722.         VERSTR
  723.         even
  724.  
  725. ExitFlag:    dc.w    0        ; set if we're to remove ourselves
  726. ClockON:    dc.w    0        ; set if SmallClock is active
  727.  
  728. ;------------------------------
  729.  
  730. _CxID:        dc.l    0
  731. _CxType:    dc.l    0
  732.  
  733. _CxSigSet:    dc.l    0
  734. _CxMessage:    dc.l    0
  735. _BrokerPort:    dc.l    0
  736. _Broker:    dc.l    0
  737.  
  738. New_Broker:    dc.b    NB_VERSION
  739.         dc.b    0
  740.         dc.l    ClockName
  741.         dc.l    ClockTitle
  742.         dc.l    ClockDescr
  743.         dc.w    NBU_UNIQUE!NBU_NOTIFY
  744.         dc.w    0
  745.         dc.b    0
  746.         dc.b    0
  747.         dc.l    0
  748.         dc.w    0
  749.  
  750. ClockTitle:    NAME
  751.         VER
  752.         dc.b    "."
  753.         REV
  754.         dc.b    0
  755.  
  756. ClockName:    NAME
  757.         dc.b    0
  758.  
  759. ClockDescr:    dc.b    "Shows time of day in a small window.",0
  760.         even
  761.  
  762. CXPRI_Text:    dc.b    "CX_PRIORITY",0
  763. CXXPOS_Text:    dc.b    "XPOS",0
  764. CXYPOS_Text:    dc.b    "YPOS",0
  765. CXFPEN_Text:    dc.b    "FRONTPEN",0
  766. CXBPEN_Text:    dc.b    "BACKPEN",0
  767.  
  768. ;--------------------------------------------------
  769.  
  770. WBName:        dc.b    "Workbench",0
  771. TEMPLATE:    dc.b    "CX_PRIORITY/N/K,XPOS/N/K,YPOS/N/K,FRONTPEN/N/K,BACKPEN/N/K",0
  772.         even
  773.  
  774. _OldLock:    dc.l    0
  775. _DiskObject:    dc.l    0
  776. Arguments:    dcb.l    5,0
  777.  
  778. ;----------------------------------------------
  779.  
  780. FrontPen:    dc.l    0
  781. BackPen:    dc.l    0
  782.  
  783. _WBFont:    dc.l    0
  784. _WBScr:        dc.l    0
  785.  
  786. WndXSize:    dc.w    0
  787. WndYSize:    dc.w    0
  788. WndXPos:    dc.l    0
  789. WndYPos:    dc.l    0
  790.  
  791. _Window:    dc.l    0
  792. WindowTags:    dc.l    WA_Left,0
  793.         dc.l    WA_Top,0
  794.         dc.l    WA_Width,0
  795.         dc.l    WA_Height,0
  796.         dc.l    WA_Borderless,TRUE
  797.         dc.l    WA_RMBTrap,TRUE
  798.         dc.l    TAG_DONE
  799.  
  800. ;-------------------------------------------------
  801.  
  802. TimeVal:    dcb.b    TV_SIZE,0
  803.  
  804. Hours:        dc.w    0
  805. Minutes:    dc.w    0
  806. Seconds:    dc.w    0
  807.  
  808. TimeIText:    dc.b    1,0            ; front & back pen
  809.         dc.b    0            ; drawmode
  810.         dc.b    0            ; KludgeFill00
  811.         dc.w    0,0            ; rel x/y
  812.         dc.l    0            ; font
  813.         dc.l    TIText
  814.         dc.l    0            ; next
  815.  
  816. TIText:    
  817. HTxt:        dc.b    "00"
  818.         dc.b    ":"
  819. MTxt:        dc.b    "00"
  820.         dc.b    "."
  821. STxt:        dc.b    "00"
  822.         dc.b    0
  823.         even
  824.